<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>
        车辆添加
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/main.css" media="all">

</head>
<body>

<div class="x-body">
    <form class="layui-form layui-form-pane" action="${pageContext.request.contextPath}/vehicle/edit" id="add" enctype="multipart/form-data" method="post">
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <div class="layui-tab-content" >
                <div class="layui-tab-item layui-show">
                    <input type="hidden" name="id" value="${v.id}">
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>所属成员
                        </label>
                        <div class="layui-input-block">
                            <select name="pid" id="personnel_id">
                                <c:forEach items="${pname}" var="pn" varStatus="status">
                                <option <c:if test="${pn.id==v.pid}" >selected</c:if> value="${pn.id}">${pn.name}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>车牌号码
                        </label>
                        <div class="layui-input-block">
                            <input type="text" name="vcard" autocomplete="off" placeholder="空制在80个汉字，160个字符以内"
                                   class="layui-input" value="${v.vcard}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>车辆颜色
                        </label>
                        <div class="layui-input-block">
                            <input type="text" name="color" autocomplete="off" placeholder="空制在80个汉字，160个字符以内"
                                   class="layui-input" value="${v.color}">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>车辆缩略图
                        </label>
                        <input type="file" id="previewImg" name="headerFile" value="${pageContext.request.contextPath}/images/${v.img}">
                    </div>

                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>描述
                        </label>
                        <div class="layui-input-block">
                            <textarea placeholder="请输入内容" name="remark" class="layui-textarea">${v.remark}</textarea>
                        </div>
                    </div>
                    <div class="layui-input-inline">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>状态
                        </label>

                        <div class="layui-input-inline">
                            <input type="radio" name="state" value="1" <c:if test="${v.state}">checked</c:if> title="可用" >
                            <div class="layui-unselect layui-form-radio layui-form-radioed"><i class="layui-anim layui-icon layui-anim-scaleSpring"></i>
                                <div>可用</div>
                            </div>
                            <input type="radio" name="state" value="0"  <c:if test="${!v.state}">checked</c:if> title="禁用">
                            <div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i>
                                <div>禁用</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <button class="layui-btn" type="submit" lay-filter="add" lay-submit="">
                            保存
                        </button>
                    </div>

                    <div style="height:100px;"></div>
                </div>
            </div>
        </div>
    </form>
</div>
<script src="${pageContext.request.contextPath}/lib/layui/layui.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath}/js/x-layui.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath}/js/jquery.min.js" charset="utf-8"></script>

<script>
    layui.use(['element','layer','form'], function(){
        form = layui.form();
        form.render();
        form.on('select(aihao)', function(data){
            communidy();
        });
        $(function () {
            communidy();
        });

        form.on('select(aihao)', function(data){
            communidy();
        });
        $(function () {
            communidy();
        });
        //communidy();
        function communidy() {
            var communidy = $("#community_id").val();
            $.ajax({
                url:"xxx",
                type:"post",
                dataType:"json",
                data:{communidy:communidy},
                success:function (data) {
                    var dlen =data.length;
                    var str='';
                    if(dlen>0){
                        for (var i=0;i<dlen;i++){
                            var dt=data[i];
                            str +='<option value="' + dt.id + '">';
                            str +=dt.member_name;
                            str +='</option>';
                        }
                    }else {
                        str +='<option value="">----暂无数据----</option>';
                    }

                    $("#personnel_id").html(str);
                    form.render('select', 'aihao');

                }
            })
        }


    })
</script>
</body>
</html>